import { post } from "../utils/Client";

/**天气类型 */
export enum WeatherType {
  /**纯净天空 */
  PureSky,
  /**多云天气 */
  CloudyWeather,
  /**大雾天气 */
  Heavyfogweather,
  /**阴天 */
  YinTian,
  /**少量云 */
  SmallAmountOfCloud,
  /**雨天 */
  RainyDay,
  /**太阳雨 */
  SunRain,
  /**雷阵雨 */
  Thunderstorm,
  /**沙尘天气 */
  DustWeather,
  /**沙尘暴 */
  Sandstorm,
  /**雪天 */
  SnowyDay,
  /**白天雪 */
  DaytimeSnow,
  /**暴风雪 */
  Blizzard12,
}

/**天空类型 */
export enum SkyBoxType {
  /**体积云 */
  VolumetricClounds,
  /**静态云 */
  StaticClouds,
  /**二维动态云 */
  DynamicClounds2D,
  /**无云 */
  SkyAtmosphere,
  /**体积极光（夜晚效果） */
  VolumetricAurota,
}

/**白天夜晚 */
export enum DayNightType {
  Day,
  Night,
}

/**天气 */
export class Weather {
  /**设置当天气 */
  static setSync(type: WeatherType) {
    return post("preview_weather", { value: type, key: "weather" });
  }

  /**
   * 设置光颜色 "255,255,255,1"
   * @param color
   * @returns
   */
  static setLightColorSync(color: string, dayNight: DayNightType) {
    return post("preview_weather", {
      value: color,
      key: `${dayNight == DayNightType.Day ? "sun" : "moon"}_color`,
    });
  }

  /**
   * 设置天气盒子"
   * @param type   盒子类型
   * @returns
   */
  static setSkyBoxSync(type: SkyBoxType) {
    return post("preview_weather", { value: type, key: "skyMode" });
  }

  /**
   * 设置光强度
   * @param intensity <=10
   * @returns
   */
  static setLightIntensitySync(intensity: number, dayNight: DayNightType) {
    return post("preview_weather", {
      value: intensity,
      key: `${dayNight == DayNightType.Day ? "sun" : "moon"}_intensity`,
    });
  }

  /**
   * 设置光角度
   * @param color
   * @returns
   */
  static setLightAngleSync(angle: number, dayNight: DayNightType) {
    return post("preview_weather", {
      value: angle,
      key: `${dayNight == DayNightType.Day ? "sun" : "moon"}_angle`,
    });
  }

  /**设置当前时间 */
  static setTimeSync(time: number) {
    return post("preview_weather", {
      value: time,
      key: "timeOfDay",
    });
  }

  /**
   * 设置黎明黄昏时间点
   * @param dawnTime 黎明的时间
   * @param duskTime 黄昏的时间
   * @param nightBrightness 夜晚的亮度  <=2
   */
  static setSegmentTimeSync(dawnTime: number, duskTime: number, nightBrightness: number) {
    return post("preview_weather", {
      dawnTime,
      duskTime,
      nightBrightness,
      key: "dusk",
    });
  }
}
